//
//  locallViewController.m
//  Protect -A
//
//  Created by 付剑英 on 16/6/15.
//  Copyright © 2016年 付剑英. All rights reserved.
//

#import "locallViewController.h"
#import "localtableview.h"
#import "firstTableviewcell.h"
#import "secondTableViewCell.h"
#import "APPTools.h"
#import "ModelOfFirst.h"
@interface locallViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,retain)localtableview *table;
@property (nonatomic,retain)NSMutableArray *arrSort;//分类
@end

@implementation locallViewController

//内存管理

-(void)dealloc{
    [self.table release];
    [super dealloc];
}


- (void)viewDidLoad {
    [super viewDidLoad];
    [self DataHandler];
    [self createTableview];
    self.navigationItem.title = @"本地";
    // Do any additional setup after loading the view.
}

#pragma mark - ------------ 解析数据 ---------------

-(void)DataHandler{
    [APPTools GETWithURL:@"https://open.seriousapps.cn/4/tab/express_product_list.json?lat=38.883349372571&lng=121.544813051798&page=0" par:nil success:^(id responseObject) {
        
        NSDictionary *dic = responseObject[1];
        NSArray *arrSORT = [[dic objectForKey:@"data"] objectForKey:@"list"];
//        NSLog(@"%@",arrSORT);
       
        self.arrSort = [ModelOfFirst modelHandleWithArrar:arrSORT];
        NSLog(@"11111%@111",_arrSort);
    } filed:^(NSError *error) {
        
    
}];
}

-(void)createTableview{
    
    self.table = [[localtableview alloc]initWithFrame:[UIScreen mainScreen].bounds style:0];
    [self.view addSubview:self.table];
    self.table.delegate   =  self;
    self.table.dataSource = self;
    [self.table registerClass:[firstTableviewcell class] forCellReuseIdentifier:@"pool"];
    [self.table registerClass:[secondTableViewCell class] forCellReuseIdentifier:@"pool1"];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 10;
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    switch (indexPath.row) {
        case 0:{
            firstTableviewcell *cell = [tableView dequeueReusableCellWithIdentifier:@"pool"];
            cell.arrSoRt = _arrSort;
            return cell;
        }
            break;
            
        default:{
        
            secondTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"pool1"];
            return cell;
        }
            break;
    }
  
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 300;

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
